@extends('layouts.admin')
@section('content')
    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <link href="/select/css/select2.css" rel="stylesheet"/>
    <script src="/select/js/select2.js"></script>
    <div class="panel   col-md-12 ">
        <div class="panel-heading">
            <h3>
                定时任务列表
            </h3>
        </div>
    </div>
    <div class="panel panel-default p  col-md-12 ">
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-bordered table-striped  table-hover">
                    <tr>
                        <td>ID</td>
                        <td>定时规则</td>
                        <td>执行脚本</td>
                        <td>操作</td>
                    </tr>
                <?php foreach ($all as $v){?>
                    <tr>
                        <td><?=$v->id?></td>
                        <td><?=$v->time?></td>

                        <td><?=$v->shell?></td>
                        <td><button class="btn btn-primary" onclick="change(<?=$v->id?>)">修改</button> | <button onclick="del(<?=$v->id?>)" class="btn btn-danger">删除</button></td>
                    </tr>
                    <?php }?>
                </table>
            </div>
            <div class="paginate">
            </div>
        </div>
    </div>
    <script>
        $("#e1").select2({
            Width:"100px",

            allowClear: true
        });
    </script>
    <script type="text/javascript">
        $("#allCheck").click(function(){

            $("input[name='change']").attr("checked","true");
        });
        function msg(msgInfo) {
            layui.use('layer', function () {
                layer.msg(msgInfo);
            })

        }
        function update() {
            var arr='';
            $("input[name=change][checked]").each(function(){
                //由于复选框一般选中的是多个,所以可以循环输出
                arr +=$(this).val()+',';
            });
            msg(arr);
        }
        function info(id) {
            window.location.href="/themeListForId?id="+id;
        }
        function update(id){
                    window.location.href="/themeUpdateForId?id="+id;
        }
        function change(id) {
            window.location.href="/changeThemeById?id="+id;

        }
        function status(id) {
            $.get('/themeStatus?theme_id='+id,function (data) {
                if(data.code==1){
                    msg(data.msg);
                    setTimeout("window.location.reload()",800);
                }else{
                    msg(data.msg);
                }

            })

        }
        function change(id){
            if(confirm('要修改么?')){
                window.location.href='/cron_change?id='+id;
            }
        }
        function del(id) {
            if(confirm('确定删除么?')) {
                $.post('/cron_delete', {'_token': '{{csrf_token()}}', 'id': id}, function (data) {
                    if (data.code == 200) {
                        window.location.reload()
                    } else {
                        alert(data.msg)
                    }

                })
            }
        }
    </script>
@endsection